package com.happyfamily.springboot.crowdsourcingplatform.dao.weng;

import com.happyfamily.springboot.crowdsourcingplatform.model.Need;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 需求Dao
 */
@Mapper
public interface NeedDao
{
	@Select("select count(*) from need")
	Long countAllNeeds();

	@Select("select * from need order by nstarttime desc  limit #{startPosition},#{limit}")
	List<Need> getAllNeedsByPage(@Param("startPosition") Integer startPosition, @Param("limit") Integer limit);

	@Delete("delete from need where nid = #{nid}")
	int deleteNeed(Long nid);

	@Select("select * from need t where t.nid = #{nid}")
	Need getById(Long nid);

	@Update("update need set nstatus = '已审核',nstate = '未中标' where nid = #{nid}")
	int passVerifyByNeedId(Long nid);

	@Update("update need set nstatus = '未过审' where nid = #{nid}")
	int unPassVerifyByNeedId(Long nid);

	Long getNeedByFuzzyNeedTitle(String ntitle, String verifyState, String tenderState, String startTime, String endTime);

	List<Need> getNeedByFuzzyNeedNamePage(String ntitle, String verifyState, String tenderState, String startTime, String endTime, Integer startPosition, Integer limit);


}
